#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
GUI启动脚本
"""

import sys
import os

try:
    from PySide6.QtWidgets import QApplication, QMessageBox
    from PySide6.QtCore import Qt
    from PySide6.QtGui import QFont
    
    from src.main_window import MainWindow
    
    def main():
        """主函数"""
        # 创建应用程序实例
        app = QApplication(sys.argv)
        
        # 设置应用程序属性
        app.setApplicationName("小说编写软件")
        app.setApplicationVersion("1.0.0")
        app.setOrganizationName("Novel Writer")
        
        # 设置全局字体
        font = QFont("Microsoft YaHei", 10)
        app.setFont(font)
        
        try:
            # 创建主窗口
            main_window = MainWindow()
            main_window.show()
            
            # 运行应用程序
            sys.exit(app.exec())
            
        except Exception as e:
            QMessageBox.critical(None, "错误", f"启动应用程序时出错: {str(e)}")
            sys.exit(1)

    if __name__ == "__main__":
        main()

except ImportError as e:
    print(f"导入模块失败: {e}")
    print("请确保已安装所有必要的依赖包")
    print("运行: pip install PySide6")
    sys.exit(1) 